<html>

<head>
<meta charset="UTF-8">
<title>职位管理</title>
</head>
<body>
	<#include "/head.ftl"/>
	<div class="content">
		<div class="tab">
			<div class="tab-header">
				<a href="/user/dept/office/add?id=${RequestParameters.id}" title="添加职位" class="btn btn-setting btn-add" id="add"> <i class="iconfont icon-add"
					style="font-size: 16px;"></i>
				</a>
				<a title="返回" class="btn btn-setting" onclick="back(this)">
					<i class="iconfont icon-undo"></i>
				</a>
				<a title="刷新" class="btn btn-setting" onclick="refresh(this)">
					<i class="iconfont icon-refresh"></i>
				</a>
				<form class="tab-tool" method="get" id="search">
					<input name="key" type="text" placeholder="按名称查找...">
					<button class="search-btn">
						<i class="iconfont icon-search"></i>
					</button>
				</form>
			</div>
			
			<div class="tab-content">
				<div>
					<table style="width: 100%; border-collapse: collapse;">
						<tr>
							<th>层次</th>
							<th>所属部门</th>
							<th>职位名称</th>
							<th>岗位薪酬</th>
							<th>操作</th>
						</tr>
						<!-- 定义职位层次 -->
						<#assign grade=1>
						<!-- 定义循环树形数据的方法 -->
						<#macro loopTree children>
							<#if children?? && children?size gt 0>
								<#list children as child>
									<tr>
										<td>${grade}</td>
										<td>${child.dept.name}</td>
										<td>${child.name}</td>
										<td>${child.salBase}</td>
										<td>
											<a href="/user/dept/office/getone?id=${RequestParameters.id}&officeid=${child.id}" title="修改职位" class="btn btn-update"><i class="iconfont icon-brush"></i><span> 修改</span></a>
											<a onclick="deleteOne(${child.id},'/user/dept/office/delete')" class="btn btn-delete"><i class="iconfont icon-trash"></i><span> 删除</span></a>
										</td>
									</tr>
									<!-- 判断是否有子节点 -->
									<#if (child.children)?? && (child.children)?size gt 0>
										<!-- 层次+1 -->
										<#assign grade=grade+1>
										<!-- 递归 -->
										<@loopTree children=child.children />
									</#if>
								</#list>
							</#if>
						</#macro>
						<!-- 调用loopTree遍历职位 -->
						<#if directOffice?size gt 0>
							<@loopTree children=directOffice />
						<#else>
							<tr><td colspan="5">该部门下没有职位</td></tr>
						</#if>
					</table>
				</div>
			</div>
		</div>

	</div>
</body>
</html>